﻿using System.Resources;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using Hallenberg.SmartClient.MVC;

namespace MenuDemo
{
    public class MvcApplication : MvcSmartClientApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );
        }

        public override string[] ModulesToLoad()
        {
            return new string[] { "MenuDemo" };
        }

        public override ResourceManager[] RegisterResourceManagers()
        {
            return new System.Resources.ResourceManager[] { Properties.Resources.ResourceManager };
        }

        public override void RegisterRoutes()
        {
            RegisterRoutes(RouteTable.Routes);
        }

        public override void InitializeApplicationValues()
        {
            // Creating test users.

            Membership.CreateUser("demouser", "demopassword");
            Membership.CreateUser("demoadm", "demopassword");

            // Create roles

            Roles.CreateRole("administrator");
            Roles.AddUserToRole("demoadm", "administrator");

            // Populate demo data provider.

            DemoData.Repository.PopulateDemoData();
        }
    }
}